<?php
  include_once('../conn.php');

  $id = $_POST['id'];
  $category_name = $_POST['category_name'];
  $category_explain = $_POST['category_explain'];
  if(strlen($category_name) < 2) {
    alert('用户名不能小于2位', 'category_list.php');
    exit();
  }

  $sql = "update category set 
    category_name = '$category_name', 
    category_explain = '$category_explain'
    where id = $id
    ";
  // echo $sql;
  $result = mysqli_query($conn, $sql);
  if($result) {
    alert('分类修改成功', 'category_list.php');
  } else {
    alert('分类修改失败', 'category_list.php');
  }

  mysqli_close($conn);
?>